#!/bin/bash

# Script to modify nic-configs for bond-with-vlans deployments

set -eux

### --start_docs

## LACP bonding using Linux bonds for bond-with-vlans deployments
## ==============================================================

## * Copy the yaml file from the standard template files directory
## ::

ORIGIN_TEMPLATES_DIR={{ overcloud_templates_path }}/network/config/bond-with-vlans
CUSTOM_TEMPLATES_DIR={{ overcloud_templates_path }}/network/config/custom-bond-with-vlans
sudo mkdir -p $CUSTOM_TEMPLATES_DIR
sudo cp $ORIGIN_TEMPLATES_DIR/*.yaml $CUSTOM_TEMPLATES_DIR/

## * Modify the yaml files to use Linux bonds
## ::

sudo grep -rl 'type: ovs_bond' $CUSTOM_TEMPLATES_DIR/ | xargs sudo sed -i 's/type: ovs_bond/type: linux_bond/g'
sudo grep -rl 'ovs_options' $CUSTOM_TEMPLATES_DIR/ | xargs sudo sed -i 's/ovs_options/bonding_options/g'

### --stop_docs
